﻿// ----------------------------------------------------------------------------------------------
// Copyright (c) Microsoft.
// ----------------------------------------------------------------------------------------------
// This source code is subject to terms and conditions of the Microsoft Public License. A 
// copy of the license can be found in the License.html file at the root of this distribution. 
// If you cannot locate the  Microsoft Public License, please send an email to 
// dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
//  by the terms of the Microsoft Public License.
// ----------------------------------------------------------------------------------------------
// You must not remove this notice, or any other, from this software.
// ----------------------------------------------------------------------------------------------

// ############################################################################
// #                                                                          #
// #        ---==>  T H I S  F I L E  I S   G E N E R A T E D  <==---         #
// #                                                                          #
// # This means that any edits to the .cs file will be lost when its          #
// # regenerated. Changes should instead be applied to the corresponding      #
// # template file (.tt)                                                      #
// ############################################################################



// ----------------------------------------------------------------------------------------------
// Hi there! This is the output of the template "Exceptions".
//
//   If you haven't already done so, please open the template file (the .tt file). The C# file is
//   generated by using the template.
//
//   For more samples and information please visit the Official T4 team blog:
//      http://blogs.msdn.com/b/t4/
//
//   Best regards,
//      The T4 Team
// ----------------------------------------------------------------------------------------------


// ReSharper disable PartialMethodWithSinglePart
// ReSharper disable PartialTypeWithSinglePart

namespace Samples
{
    using System;
    using System.Runtime.Serialization;
    using System.Security;

    
    /// <summary>
    /// The Test exception (derived from Exception)
    /// </summary>
    [Serializable]
    partial class TestException 
        :   Exception
    {
        // --------------------------------------------------------------------
        // "Static" events are used to override behavior of TestException
        //
        // The way a developer overrides this behavior is by defining a partial
        // class in another file, and adding a partial method with the same
        // signature as below
        // --------------------------------------------------------------------

        // If the class needs custom action on construction, this is the partial 
        // method to override
        partial void OnConstructed (Exception innerException, string message);

        // If the class needs custom serialization code, these are the partial 
        // methods to override
        partial void OnSerialize (SerializationInfo info, StreamingContext context);
        partial void OnUnserialize (SerializationInfo info, StreamingContext context);

        // --------------------------------------------------------------------

        // --------------------------------------------------------------------
        // TestException constructors
        // --------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the TestException class  
        /// </summary>
        public TestException ()
            :   this (null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the TestException class with a 
        /// specified error message.
        /// </summary>
        /// <param name="message">
        /// The error message that explains the reason for the exception.
        /// </param>
        public TestException (string message)
            :   this (message, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the TestException class with a 
        /// reference to the inner exception that is the cause of this exception.
        /// </summary>
        /// <param name="innerException">
        /// The exception that is the cause of the current exception, or a null reference 
        /// (Nothing in Visual Basic) if no inner exception is specified.
        /// </param>
        public TestException (Exception innerException)
            :   this (null, innerException)
        {
        }

        /// <summary>
        /// Initializes a new instance of the TestException class with a 
        /// specified error message and a reference to the inner exception that 
        /// is the cause of this exception.
        /// </summary>
        /// <param name="message">
        /// The error message that explains the reason for the exception.
        /// </param>
        /// <param name="innerException">
        /// The exception that is the cause of the current exception, or a null reference 
        /// (Nothing in Visual Basic) if no inner exception is specified.
        /// </param>
        public TestException (string message, Exception innerException)
            :   base (message ?? @"TestException", innerException)
        {
            OnConstructed (innerException, message ?? @"TestException");
        }

        // --------------------------------------------------------------------
        // TestException serialization code
        // --------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the TestException class with serialized data.
        /// </summary>
        /// <param name="info">
        /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 
        /// object data about the exception being thrown.
        /// </param>
        /// <param name="context">
        /// The System.Runtime.Serialization.StreamingContext that contains contextual 
        /// information about the source or destination.
        /// </param>
        [SecuritySafeCritical]
        protected TestException (SerializationInfo info, StreamingContext context)
            :   base (info, context)
        {
            OnUnserialize (info, context);
        }        

        /// <summary>
        /// When overridden in a derived class, sets the 
        /// System.Runtime.Serialization.SerializationInfo with information about the exception.
        /// </summary>
        /// <param name="info">
        /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 
        /// object data about the exception being thrown.
        /// </param>
        /// <param name="context">
        /// The System.Runtime.Serialization.StreamingContext that contains contextual 
        /// information about the source or destination.
        /// </param>
        public override void GetObjectData (SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            OnSerialize (info, context); 
        }
    }

    
    /// <summary>
    /// The DerivedFromTest exception (derived from TestException)
    /// </summary>
    [Serializable]
    partial class DerivedFromTestException 
        :   TestException
    {
        // --------------------------------------------------------------------
        // "Static" events are used to override behavior of DerivedFromTestException
        //
        // The way a developer overrides this behavior is by defining a partial
        // class in another file, and adding a partial method with the same
        // signature as below
        // --------------------------------------------------------------------

        // If the class needs custom action on construction, this is the partial 
        // method to override
        partial void OnConstructed (Exception innerException, string message);

        // If the class needs custom serialization code, these are the partial 
        // methods to override
        partial void OnSerialize (SerializationInfo info, StreamingContext context);
        partial void OnUnserialize (SerializationInfo info, StreamingContext context);

        // --------------------------------------------------------------------

        // --------------------------------------------------------------------
        // DerivedFromTestException constructors
        // --------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the DerivedFromTestException class  
        /// </summary>
        public DerivedFromTestException ()
            :   this (null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the DerivedFromTestException class with a 
        /// specified error message.
        /// </summary>
        /// <param name="message">
        /// The error message that explains the reason for the exception.
        /// </param>
        public DerivedFromTestException (string message)
            :   this (message, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the DerivedFromTestException class with a 
        /// reference to the inner exception that is the cause of this exception.
        /// </summary>
        /// <param name="innerException">
        /// The exception that is the cause of the current exception, or a null reference 
        /// (Nothing in Visual Basic) if no inner exception is specified.
        /// </param>
        public DerivedFromTestException (Exception innerException)
            :   this (null, innerException)
        {
        }

        /// <summary>
        /// Initializes a new instance of the DerivedFromTestException class with a 
        /// specified error message and a reference to the inner exception that 
        /// is the cause of this exception.
        /// </summary>
        /// <param name="message">
        /// The error message that explains the reason for the exception.
        /// </param>
        /// <param name="innerException">
        /// The exception that is the cause of the current exception, or a null reference 
        /// (Nothing in Visual Basic) if no inner exception is specified.
        /// </param>
        public DerivedFromTestException (string message, Exception innerException)
            :   base (message ?? @"DerivedFromTestException", innerException)
        {
            OnConstructed (innerException, message ?? @"DerivedFromTestException");
        }

        // --------------------------------------------------------------------
        // DerivedFromTestException serialization code
        // --------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the DerivedFromTestException class with serialized data.
        /// </summary>
        /// <param name="info">
        /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 
        /// object data about the exception being thrown.
        /// </param>
        /// <param name="context">
        /// The System.Runtime.Serialization.StreamingContext that contains contextual 
        /// information about the source or destination.
        /// </param>
        [SecuritySafeCritical]
        protected DerivedFromTestException (SerializationInfo info, StreamingContext context)
            :   base (info, context)
        {
            OnUnserialize (info, context);
        }        

        /// <summary>
        /// When overridden in a derived class, sets the 
        /// System.Runtime.Serialization.SerializationInfo with information about the exception.
        /// </summary>
        /// <param name="info">
        /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 
        /// object data about the exception being thrown.
        /// </param>
        /// <param name="context">
        /// The System.Runtime.Serialization.StreamingContext that contains contextual 
        /// information about the source or destination.
        /// </param>
        public override void GetObjectData (SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            OnSerialize (info, context); 
        }
    }

    
    /// <summary>
    /// The StatusCode exception (derived from Exception)
    /// </summary>
    [Serializable]
    partial class StatusCodeException 
        :   Exception
    {
        // --------------------------------------------------------------------
        // "Static" events are used to override behavior of StatusCodeException
        //
        // The way a developer overrides this behavior is by defining a partial
        // class in another file, and adding a partial method with the same
        // signature as below
        // --------------------------------------------------------------------

        // If the class needs custom action on construction, this is the partial 
        // method to override
        partial void OnConstructed (Exception innerException, string message);

        // If the class needs custom serialization code, these are the partial 
        // methods to override
        partial void OnSerialize (SerializationInfo info, StreamingContext context);
        partial void OnUnserialize (SerializationInfo info, StreamingContext context);

        // --------------------------------------------------------------------

        // --------------------------------------------------------------------
        // StatusCodeException constructors
        // --------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the StatusCodeException class  
        /// </summary>
        public StatusCodeException ()
            :   this (null, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the StatusCodeException class with a 
        /// specified error message.
        /// </summary>
        /// <param name="message">
        /// The error message that explains the reason for the exception.
        /// </param>
        public StatusCodeException (string message)
            :   this (message, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the StatusCodeException class with a 
        /// reference to the inner exception that is the cause of this exception.
        /// </summary>
        /// <param name="innerException">
        /// The exception that is the cause of the current exception, or a null reference 
        /// (Nothing in Visual Basic) if no inner exception is specified.
        /// </param>
        public StatusCodeException (Exception innerException)
            :   this (null, innerException)
        {
        }

        /// <summary>
        /// Initializes a new instance of the StatusCodeException class with a 
        /// specified error message and a reference to the inner exception that 
        /// is the cause of this exception.
        /// </summary>
        /// <param name="message">
        /// The error message that explains the reason for the exception.
        /// </param>
        /// <param name="innerException">
        /// The exception that is the cause of the current exception, or a null reference 
        /// (Nothing in Visual Basic) if no inner exception is specified.
        /// </param>
        public StatusCodeException (string message, Exception innerException)
            :   base (message ?? @"StatusCodeException", innerException)
        {
            OnConstructed (innerException, message ?? @"StatusCodeException");
        }

        // --------------------------------------------------------------------
        // StatusCodeException serialization code
        // --------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the StatusCodeException class with serialized data.
        /// </summary>
        /// <param name="info">
        /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 
        /// object data about the exception being thrown.
        /// </param>
        /// <param name="context">
        /// The System.Runtime.Serialization.StreamingContext that contains contextual 
        /// information about the source or destination.
        /// </param>
        [SecuritySafeCritical]
        protected StatusCodeException (SerializationInfo info, StreamingContext context)
            :   base (info, context)
        {
            OnUnserialize (info, context);
        }        

        /// <summary>
        /// When overridden in a derived class, sets the 
        /// System.Runtime.Serialization.SerializationInfo with information about the exception.
        /// </summary>
        /// <param name="info">
        /// The System.Runtime.Serialization.SerializationInfo that holds the serialized 
        /// object data about the exception being thrown.
        /// </param>
        /// <param name="context">
        /// The System.Runtime.Serialization.StreamingContext that contains contextual 
        /// information about the source or destination.
        /// </param>
        public override void GetObjectData (SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            OnSerialize (info, context); 
        }
    }

}
